<template>
	<view style="width: 100%; height: 100%;">
		<!-- 加载组件 -->
		<subVipBuy ref="subVipBuy" @payed="EventPayok" @navAddress="EventNavAddre"></subVipBuy>

		<!-- 顶部自定义导航 -->
		<tn-navbar :placeholder="true" fixed bg-color="#FFFFFF00" text-color="#fff"> {{title}}
		</tn-navbar>
	</view>
</template>

<script>
	import utils from '@/common/utils';
	import subVipBuy from '../components/sub-vip-buy/sub-vip-buy.vue'
	export default {
		data() {
			return {
				title: '升级会员',
				sConf: getApp().globalData,
				staffData: null, // 个人信息
			}
		},
		onLoad() {
			this.loadStaffRead(this.sConf.auth.id)
		},
		onReady() {

		},
		components: {
			subVipBuy
		},
		methods: {
			/**
			 * 加载用户信息
			 */
			loadStaffRead(e) {
				let host = this.sConf.host + '/weapps/userinfo/' + e + '/';
				let token = this.sConf.token || '';
				utils.authenticatorOnRead(host, token).then((res) => {
					console.log('加载个人信息', res);
					this.staffData = res;
					this.$refs.subVipBuy.loadDefData(res);
				})
			},
			/**
			 * 支付成功回调
			 * @param {Object} e
			 */
			EventPayok(e) {
				uni.redirectTo({
					url: '/pageb/reqsn/paystate?reqsn=' + e
				})

			},
			/**
			 * 跳转到地址
			 */
			EventNavAddre() {
				uni.redirectTo({
					url: '/pageb/userinfo/address'
				})
			}
		}
	}
</script>

<style>

</style>